package com.trkj.utils;

import java.text.SimpleDateFormat;

import com.trkj.pojo.Dept;
import com.trkj.pojo.Employ;
import com.trkj.pojo.Loan;
import com.trkj.pojo.Overwork;
import com.trkj.pojo.Position;
import com.trkj.pojo.Quit;
import com.trkj.pojo.Standard;
import com.trkj.vo.EmployVo;
import com.trkj.vo.LoanVo;
import com.trkj.vo.OverWorkVo;
import com.trkj.vo.QuitVo;
import com.trkj.vo.StandardVo;

public class PojoToVo {
	public static EmployVo EmployToEmployVo(Employ employ) {
		EmployVo employVo = new EmployVo();
		employVo.setEmployBirth(employ.getEmployBirth());
		Dept dept = employ.getDept();
		Position position = employ.getPosition();
		if (dept!=null) {
			employVo.setDeptVoName(dept.getDeptName());
		}
		if (position!=null) {
			employVo.setPositionVoName(position.getPositionName());
		}
		employVo.setEmployContracttype(employ.getEmployContracttype());
		employVo.setEmployContractyears(employ.getEmployContractyears());
		employVo.setEmployEducation(employ.getEmployEducation());
		employVo.setEmployGraduatetime(employ.getEmployGraduatetime());
		employVo.setEmployMajor(employ.getEmployMajor());
		employVo.setEmployVoMarriage(employ.getEmployMarriage()==1?"已婚":"未婚");
		employVo.setEmployName(employ.getEmployName());
		employVo.setEmployNative(employ.getEmployNative());
		employVo.setEmployNature(employ.getEmployNature());
		employVo.setEmployPosttime(employ.getEmployPosttime());
		employVo.setEmployProbationary(employ.getEmployProbationary());
		employVo.setEmployResidence(employ.getEmployResidence());
		employVo.setEmploySalary(employ.getEmploySalary());
		employVo.setEmploySchool(employ.getEmploySchool());
		employVo.setEmployVoSex(employ.getEmploySex()==1?"男":"女");
		return employVo;
	}

	public static LoanVo LoanToLoanVo(Loan loan) {
		LoanVo loanVo = new LoanVo();
		loanVo.setLoanName(loan.getEmp().getEmpName());
		if (loan.getDept()!=null) {
			loanVo.setLoanDept(loan.getDept().getDeptName());
		}
		loanVo.setLoanBigmoney(loan.getLoanBigmoney());
		loanVo.setLoanExplain(loan.getLoanExplain());
		loanVo.setLoanMoney(loan.getLoanMoney());
		loanVo.setLoanUptime(loan.getLoanUptime());
		loanVo.setLunchPeople(loan.getLunchPeople());
		loanVo.setEmpLoanbalance(loan.getEmp().getEmpLoanbalance()+"");
		return loanVo;
	}

	public static QuitVo QuitToQuitVo(Quit quit) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		QuitVo quitVo = new QuitVo();
		if (quit.getDept()!=null) {
			quitVo.setDeptName(quit.getDept().getDeptName());
			quitVo.setDeptId(quit.getDept().getDeptId());
		}
		if (quit.getPosition()!=null) {
			quitVo.setPositionId(quit.getPosition().getPositionId());
			quitVo.setPositionName(quit.getPosition().getPositionName());
		}
		quitVo.setEmpId(quit.getEmp().getEmpId());
		quitVo.setEmpName(quit.getEmp().getEmpName());
		quitVo.setQuitUptime(sf.format(quit.getQuitUptime()));
		quitVo.setQuitTime(sf.format(quit.getQuitTime()));
		quitVo.setQuitType(quit.getQuitType().toString());
		quitVo.setQuitExplain(quit.getQuitExplain());
		return quitVo;
	}

	public static StandardVo StandardToStandardVo(Standard standard) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		StandardVo standardVo = new StandardVo();
		standardVo.setStandardUptime(sf.format(standard.getStandardUptime()));
		if (standard.getDept()!=null) {
			standardVo.setDeptId(standard.getDept().getDeptId());
			standardVo.setDeptName(standard.getDept().getDeptName());
		}
		standardVo.setEmpId(standard.getEmp().getEmpId());
		standardVo.setEmpName(standard.getEmp().getEmpName());
		standardVo.setLunchPeople(standard.getLunchPeople());
		standardVo.setStandardEntertime(sf.format(standard.getStandardEntertime()));
		standardVo.setStandardTrialtime(sf.format(standard.getStandardTrialtime()));
		standardVo.setStandardTime(sf.format(standard.getStandardTime()));
		standardVo.setStandardExplain(standard.getStandardExplain());
		return standardVo;
	}

	public static OverWorkVo OverworkToOverWorkVo(Overwork overwork) {
		if (overwork!=null) {
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			OverWorkVo overWorkVo = new OverWorkVo();
			if (overwork.getDept()!=null) {
				overWorkVo.setDeptId(overwork.getDept().getDeptId());
				overWorkVo.setDeptName(overwork.getDept().getDeptName());
			}
			overWorkVo.setEmpId(overwork.getEmp().getEmpId());
			overWorkVo.setEmpName(overwork.getEmp().getEmpName());
			overWorkVo.setOverworkDay(overwork.getOverworkDay()+"");
			overWorkVo.setOverworkEndtime(sf.format(overwork.getOverworkEndtime()));
			overWorkVo.setOverworkExplain(overwork.getOverworkExplain());
			overWorkVo.setOverworkStarttime(sf.format(overwork.getOverworkStarttime()));
			overWorkVo.setOverworkUptime(sf.format(overwork.getOverworkUptime()));
			if (overwork.getPosition()!=null) {
				overWorkVo.setPositionId(overwork.getPosition().getPositionId());
				overWorkVo.setPositionName(overwork.getPosition().getPositionName());
			}
			return overWorkVo;
		}
		return null;
	}
}
